package com.ludomancy.gamelib.ui;

import java.awt.Graphics;
import java.awt.Rectangle;

import com.ludomancy.gamelib.Layout;
import com.ludomancy.gamelib.Widget;

public class DialogWidget extends Widget
{
	public interface DialogListener
	{
		void onDialogClosed(DialogWidget widget);
	}

	private Widget[] buttons;

	public DialogWidget(Widget parent, Rectangle area)
	{
		super(parent, area);
	}
	
	protected void initDialog(Widget[] initialButtons)
	{
		this.buttons = initialButtons;
		// place buttons
		if(buttons.length > 0)
		{
			Layout.doLayout(new Widget[][]{buttons}, 5, 0, 0);
			for (int i = 0; i < buttons.length; i++)
			{
				Button b = (Button) buttons[i];
				b.setRelativePosition(buttons[i].getX(), getHeight()-buttons[i].getHeight()-5);
			}
		}
	}
	
	public Rectangle getDialogArea()
	{
		Rectangle client = (Rectangle) getClientRect().clone();
		client.height -= buttons[0].getHeight();
		return client;
	}

	public void paint(Graphics g)
	{
	}
}
